<template>
  <div id="app">
    <router-view/>
  </div>
</template>
<script>
export default {
    data() {
        return {
            
        }
    },
    mounted() {
        this.setUsername_name()
        setInterval(() => {
            if(window.sessionStorage.getItem("account")){
            this.login()
            }
        },60000);
    },
    methods: {
        setUsername_name(){
             let account= window.sessionStorage.getItem("account")
             let name= window.sessionStorage.getItem("name")
             this.$store.dispatch('saveUserName',account)
             this.$store.dispatch('saveName',name)
        },
        login(){
          this.axios.post('/user/login/',{
              username:window.sessionStorage.getItem('account'),
              password:window.sessionStorage.getItem('password')
          }).then((res)=>{
              window.sessionStorage.setItem("token", 'JWT '+res.token)
          })
        }
    },
}
</script>
<style lang="scss">

</style>
